package day05;

public class Utils {


    public static int addition(int n) {
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            sum += i;
        }
        return sum;
    }


    public static int multiplication(int n) {
        int result = 1;
        for (int i = 1; i <= n; i++) {
            result *= i;
        }
        return result;
    }


    public static void bubbleSort(int[] array) {
        int n = array.length;
        for (int i = 0; i < n - 1; i++) {
            for (int j = 0; j < n - i - 1; j++) {
                if (array[j] > array[j + 1]) {
                    // 交换元素
                    int temp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = temp;
                }
            }
        }

        for (int value : array) {
            System.out.print(value + " ");
        }
    }


    public static boolean isEven(int number) {
        return number % 2 == 0;
    }

    public static void main(String[] args) {

        System.out.println(addition(9));


        System.out.println(multiplication(9));


        int[] array = {64, 34, 25, 12, 22, 11, 90};
        bubbleSort(array);


        System.out.println(isEven(8));
        System.out.println(isEven(9));
    }
}

